# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=marshmallow-sqlalchemy
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.29.0
pkgrel=2
pkgdesc='SQLAlchemy integration with marshmallow (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/marshmallow-code/marshmallow-sqlalchemy'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-marshmallow"
         "${MINGW_PACKAGE_PREFIX}-python-sqlalchemy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-$pkgver.tar.gz::${url}/archive/${pkgver}.tar.gz")
sha256sums=('cd2f8d56e65304f22e7b982a2c21acd044b067fbe02a9795570dbf05b5d0f7ad')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/python setup.py install --optimize=1 --skip-build \
      --prefix=${MINGW_PREFIX} \
      --root="${pkgdir}"

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
